﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClinicalMassageSystem
{
    public partial class PatientInjuryScreen : Form
    {
        int patientID;
        string bodyPartName;
        int bodyPartNumber;
        int firstTime = 0;
        

        CMSDataContext cms = new CMSDataContext();

        public PatientInjuryScreen()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void PatientInjuryScreen_Load(object sender, EventArgs e)
        {
            lblInjuredPart.Text = "Body Part: " + bodyPartName;

            var query = from i in cms.InjuryParts
                        where (i.PatientID == patientID && i.PartID == bodyPartNumber) //Error saying PatientID column does not exist
                        select i;
          

            if (query.Count().ToString() == "0")
            {
                firstTime = 1;
            }
            else
            {
                foreach (var q in query)
                {
                    txtPainScale.Text = q.PainScale.ToString();
                    txtNotes.Text = q.Notes.ToString();

                }
            }


        }
        public void setScreen(string patiendID,int bodyPart)
        {
            patientID = Int16.Parse(patiendID);
            bodyPartNumber = bodyPart;

            if (bodyPart == 1)
            {
                bodyPartName = "Head";
            }
            else if (bodyPart == 2)
            {
                bodyPartName = "Left Arm";
            }
            else if (bodyPart == 3)
            {
                bodyPartName = "Left Torso";
            }
            else if (bodyPart == 4)
            {
                bodyPartName = "Right Torso";
            }
            else if (bodyPart == 5)
            {
                bodyPartName = "Right Arm";
            }
            else if (bodyPart == 6)
            {
                bodyPartName = "Left Leg";
            }
            else if (bodyPart == 3)
            {
                bodyPartName = "Right Leg";
            }
        }

        private void btnUpdateNotes_Click(object sender, EventArgs e)
        {
            cms.SubmitChanges();
            if (firstTime == 1)
            {
                //add new item to database
                

            }
            else
            {
                //update database
            }
        }

        private void patientBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }
    }
}
